A branch target buffer (BTB) is a memory element associated with a pipeline in a processor and which stores information about previously executed branch instructions of a computer program. A branch predictor uses the data stored in the BTB to predict the direction that the program flow will take in the case of instructions known to cause possible flow changes, such as branch instructions. A BTB therefore uses information about program flow in the past to predict the current program flow. Branch prediction is useful as it enables instructions to be speculatively executed by the processor before the outcome of the prediction is known.
The embodiments described below are provided by way of example only and are not limiting of implementations which solve any or all of the disadvantages of known branch predictors and BTBs.